package com.example.experiment6.view;

import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;

import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.PrecomputedText;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.example.experiment6.R;
import com.example.experiment6.presenter.QRcodePresenter;

import java.util.Timer;
import java.util.TimerTask;

public class MainActivity extends AppCompatActivity {

    QRcodePresenter qRcodePresenter;
    AlertDialog.Builder showImage;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        showImage=new AlertDialog.Builder(this);
        qRcodePresenter=new QRcodePresenter();
        EditText editText=findViewById(R.id.getString);
        Button button=findViewById(R.id.createQRcode);

        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                ImageView imageView=new ImageView(MainActivity.this);
                LinearLayout linearLayout=new LinearLayout(MainActivity.this);
                LinearLayout.LayoutParams layoutParams=new LinearLayout.LayoutParams(500,500,1);
                imageView.setLayoutParams(layoutParams);

                linearLayout.addView(imageView);
                showImage.setView(linearLayout);
                qRcodePresenter.getImage(editText.getText().toString(),imageView);
                showImage.show();
            }
        });
    }

}
